<?php
/**
 * +------ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER * ---------+
 * +----------------------------------------------------------------------------+
 * | PHPKiisf - Keep It in Simple Framework										|
 * | Version 1.0																|
 * | Copyright (C) <2013>  Mario Cezzare <mcezzare@gmail.com>					|
 * | Blog: http://mcezzare.blogspot.com.br										|
 * |																			|
 * | This program is part of PHPKiisf, and is free software: you can			|
 * | redistribute it and/or modify it under the terms of the GNU 				|
 * | General Public License as published by										|
 * | the Free Software Foundation, either version 3 of the License, or			|
 * | (at your option) any later version.										|
 * |																			|
 * | This program is distributed in the hope that it will be useful,			|
 * | but WITHOUT ANY WARRANTY; without even the implied warranty of				|
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the				|
 * | GNU General Public License for more details.								|
 * | You should have received a copy of the GNU General Public License			|
 * | along with this program.  If not, see <http://www.gnu.org/licenses/>.		|
 * +----------------------------------------------------------------------------+
 * | Author : <Mario Cezzare Angelicola Chiodi> <mcezzare@gmail.com>			|
 * +----------------------------------------------------------------------------+
 * | Contributors																|
 * |																			|
 * +----------------------------------------------------------------------------+
 *
 */
/**
 * This file is the view used for build MVC objects
 *
 * @package Templates
 * @access public
 * @since 2013-03-08
 * @author Mario Cezzare <mcezzare@gmail.com>
 */
?>

<?php
require_once sprintf( "%s/%s%s" , base_template::$public_dir , 'header' , INCLUDE_EXTENSION );

require_once sprintf( "%s/%s%s" , base_template::$public_dir , 'navbar' , INCLUDE_EXTENSION );


//just to minify
$global_params	 = base_template::$global_params;
/**
* Verifiy if this page is running on test mode
*/
$test_mode		 = false;
if ( is_array( $global_params ) ) {
	if ( in_array( "test" , $global_params[ 0 ] ) ) {
		$test_mode = true;
	}
}

$uml			 = new phpuml();
/**
 * Define path to start scan
 * @var String
 */
$start_folder	 = $_SERVER[ "DOCUMENT_ROOT" ];

//$start_folder	 	 = substr( $start_folder	  , 0 , strlen( $start_folder	  ) - 1 );
$uml->start_path = $start_folder	 ;
$list_files = $uml->get_list_files( false ) ;

/**
 * [$clean_list description]
 * @var array
 */
$clean_list = array();
//uncomment for debug
//echo __FILE__ . "<br>" ;
//print_r( dispatcher::$_active_route ) ;
//print_r( $global_params ) ;
?>


<div class="container">
		<div class="hero-unit">
				<h1>
						<?= base_template::$section_name; ?>

				</h1>
				<p>-----</p>

		<!--<p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>-->
		</div>
		<div class="container">
				<!--form-inline container-fluid-->
<!-- 				<div class="accordion-heading">
						<ul class="nav nav-tabs nav-stacked">
								<li><a href="#model">1 - Check Files</a></li>
																<li><a href="#database">2 - Configuring Database Access</a></li>
																<li><a href="#mvc_gen">3 - Generating Php Code for Bussiness Objects</a></li>
						</ul>

						<p>&nbsp;</p>

				</div> -->
				<?php /* start tables builder form */ ?>
				<div class="container-fluid">
						<!-- <h4>Files</h4> -->
						<?php
						$div_name		 = 'files';
						// gui_controller::create_button( array(
						// "id" => sprintf( "bt_view_%s" , $div_name ) ,
						// "onclick" => "phpkiisf_js.display_box(this,$('#div_$div_name'));" ,
						// "class" => "btn btn-small" ,
						// "value" => "Hide Details &raquo;" ,
						// ) );
						?>
						<!-- <div data-collapsed="false" id="<? printf( "div_%s" , $div_name ); ?>" class="simple_border" style="display: block"> -->

							 <?

							 ?>
				<!-- </div> -->
		</div>
		<?php /* start process tables */ ?>
		<div class="container-fluid">
				<?php
				// $table_name = read_var( "mysql_tables" , "P" );
				/* in php5.3 this test is false only Post is null  */
				// if ( $table_name ) {
				// printf( "<h2>Dumping table :%s</h2>" , $table_name );
				?>
		</div>
		<div class="accordion" id="accordion2">
				<div class="accordion-group">
						<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
										List of php Files
								</a>
						</div>
						<div id="collapseOne" class="accordion-body collapse">
								<div class="accordion-inner">
										<pre>
<?php 

foreach ($list_files as $key => $value) { 
	$have_files =  is_array($value) ;
	print "[$key]:<br>" ;
	foreach ($value as $folder => $filename ) {

		if (substr($filename, -3) == "php" && $filename!= "empty.php"){
			print "-$filename<br>" ;
			array_push( $clean_list, "$key/$filename" ) ;
		}
	}

}

?>
										</pre>
								</div>
						</div>
				</div>
				<div class="accordion-group">
						<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
										Check Files Builty
								</a>
						</div>
						<!-- <div id="collapseTwo" class="accordion-body collapse in"> -->
						<div id="collapseTwo" class="accordion-body collapse">
								<div class="accordion-inner">
									<ul  class="accordion" id="accordion3">
										<?php 
										 	$index_folder = 0;
										 	foreach ($list_files as $key => $value) { 
										 		$have_files =  is_array($value) ;	
										?>
										 		<li class="accordion-group">
										 			<a id="link_folder<?= $index_folder; ?>" data-toggle="collapse" data-parent="#accordion3" href="#collapse<?=$index_folder?>">
										 				<img class="icon-folder-<?php print ( $have_files ) ? "close" : "open" ; ?>" /><?= $key; ?>
										 			</a>
										 			<?php if ( $have_files ) {
										 				printf ("<ul id=\"collapse%s\" class=\"accordion-body collapse\">", $index_folder);
										 				foreach ($value as $key => $filename ) {
										 					printf ( "<li><img class=\"%s\" />%s</li>", "icon-file", $filename ) ;
										 				}
										 				print "</ul>";
										 			?>
										 			
										 			<?php } ?>
										 		</li>
										<?php 
										$index_folder++ ;
										} ?>
									</ul>	 
								</div>
						</div>
				</div>
				<div class="accordion-group">
						<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
										UML model - Generate
								</a>
						</div>
						<div id="collapseThree" class="accordion-body collapse">
								<div class="accordion-inner">
									<pre>
<?php
// var_dump($clean_list);
for ( $f = 0 ; $f < count( $clean_list ) ; $f++ ) {
	$filename_full = $clean_list[$f] ;
	echo $filename_full . "<br>" ;
	$uml->detect_class($filename_full) ;

	// if ( $f== 5 ) break;
}
var_dump( $uml->list_classes );
printf( "Total classes: %d <br> " , count($uml->list_classes ) );
?>

									<pre>
								</div>
						</div>
				</div>
				<div class="accordion-group">
						<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseFour">
										UML model - Preview
								</a>
						</div>
						<div id="collapseFour" class="accordion-body collapse in">
								<div class="accordion-inner">
<?php
printf( "Parent classes:  %d <br> " , count($uml->parent_classes ));
foreach ( $uml->parent_classes as $class => $item ) {
	
	$uml->create_box($item);
}

?>
								</div>
						</div>
				</div>
		</div>
		<? // }
		?>
		<div class="span12">

				<hr>
				<footer>
						<p>
								&copy; <a href="<?= FMW_URL_ABOUT; ?>" target="_blank">PHPKissf 2013</a>
						</p>
				</footer>
		</div>
</div>
</div>
<script language="javascript">
		$(document).ready(function() {
				
		});
</script>
<!-- /container -->
<?
require_once sprintf( "%s/%s%s" , base_template::$public_dir , 'footer' , INCLUDE_EXTENSION );
?>